/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ttt.nor2.util;

import java.io.FileInputStream;
import java.util.Properties;

/**
 *
 * @author Administrator
 */
public class ChkArgs {

    private String fileConfig = "";
    private Properties props = null;

    public String getFileConfig() {
        return fileConfig;
    }

    public Properties getProps() {
        return props;
    }

    public ChkArgs(String[] args) {

        // Checking Config Argument File
        try {
            if (args[0] == null) {
                System.out.println("Can not find logger properties file name, Ex>java  ServiceName fileproperties.properties");
                System.out.println("Terminate application");
                System.exit(-1);
            } else {
                fileConfig = args[0];
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Terminate application");
            System.exit(-1);
        }
        String path = System.getProperty("user.dir") + System.getProperty("file.separator");
        fileConfig = path + fileConfig;

        props = new Properties();

        try {
            props.load(new FileInputStream(fileConfig));
        } catch (Exception e) {
            System.err.println("Exception : load file properties error! " + ExceptionUtil.getStackTrace(e));
            System.exit(-1);
        }
    }
}
